﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TmU220PrintHelperV2d0.Entity;
using TmU220PrintHelperV2d0.HttpHelper;
using TmU220PrintHelperV2d0.Singleton;
using ZhangLogSysV1d0;

namespace TmU220PrintHelperV2d0.Service
{
    public class DatabaseHelperV3d0
    {
        /// <summary>
        /// 读取rms_order_print_main表和rms_order_print_detail表，返回主打印数据类（包含打印明细项）
        /// </summary>
        /// <returns></returns>
        public static List<rms_order_print_main> GetPrintMain()
        {
            List<rms_order_print_main> printMainList = new List<rms_order_print_main>();
            try
            {
                printMainList = OrderPrintMainAndDetailSingletonV3d0.Instance.GetPrintMainList();
            }
            catch (Exception ex)
            {
                SimpleLoger.Instance.Error(ex);
            }
            return printMainList;
        }
        /// <summary>
        /// 得到 rms_order_print_log数据表的记录
        /// </summary>
        /// <param name="startTime">起始时间</param>
        /// <returns></returns>
        public static List<rms_order_print_log> GetPrintLog(DateTime startTime,DateTime endTime)
        {
            List<rms_order_print_log> printLogList = new List<rms_order_print_log>();
            try
            {
                string sqlString = "select * from rms_order_print_log where addtime between '" +
                    startTime.ToString("yyyy-MM-dd") + "' " +
                    "and '" + endTime.ToString("yyyy-MM-dd") + "'";
                string jsonResult = GetDataBySQLSingletonV1d0.Instance.Run(sqlString);
                printLogList = JsonConvert.DeserializeObject<List<rms_order_print_log>>(jsonResult);
                //var resultList=HotchPotchV2d0.SqlLoadDataOfTableByApiInterface<rms_order_print_log>(sqlString);
                //if (resultList != null) printLogList = resultList;
            }
            catch (Exception ex)
            {
                SimpleLoger.Instance.Error(ex);
            }
            return printLogList;
        }


    }
}
